﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using SES.CMS.BL;
using SES.CMS.DO;

namespace SES.CMS.Module
{
    public partial class ucHomeArticle : System.Web.UI.UserControl
    {
        cmsArticleBL artBL = new cmsArticleBL();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                rptHomepageArticleDatasource();
                rptHomeCateNewsDatasource();
            }
        }

        protected void rptHomepageArticleDatasource()
        {
            rptLastestNews.DataSource = artBL.LastestNews();
            rptLastestNews.DataBind();
        }

        protected void rptHomeCateNewsDatasource()
        {
            DataTable dtHomePage = new cmsCategoryBL().SelectHomepageByType(1, false);
            if (dtHomePage.Rows.Count > 0)
            {
                ltrHomeCate.Text = dtHomePage.Rows[0]["Title"].ToString();
                rptHomeCateNews.DataSource = artBL.SelectByCategoryAndNumber(int.Parse(dtHomePage.Rows[0]["CategoryID"].ToString()),8);
                rptHomeCateNews.DataBind();
            }
        }
        public string FriendlyUrl(string s)
        {
            return Ultility.Change_AV(s);
        }
        public string WordCut(string text)
        {
            return Ultility.WordCut(text, 65, new char[] { ' ', '.', ',', ';' }) + "...";
        }
    }
}